<%@ taglib uri="/WEB-INF/struts-bean" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic" prefix="logic" %>

<logic:messagesPresent message="true">
	<html:img pageKey="sistema.ico.informacao" align="absmiddle"/>
	<bean:message key="mensagem.informacoes"/>
	<ul>
		<html:messages id="mensagem" message="true">
			<li><bean:write name="mensagem" ignore="false"/></li>
		</html:messages>
	</ul>
</logic:messagesPresent>

<table class="tbForm">
	<tr>
		<th colspan="2" align="center"><bean:message key="formulario.venda" /></th>
	</tr>
	<tr>
		<td align="right" width="50%"><bean:message key="formulario.venda.dataVenda" />: </td>
		<td align="left" width="50%"><bean:write name="venda" property="dataVenda" formatKey="sistema.padrao.data"/></td>
	</tr>
	<tr>
		<td align="right" width="50%"><bean:message key="formulario.venda.cliente" />: </td>
		<td align="left" width="50%"><bean:write name="venda" property="cliente.nome"/></td>
	</tr>
	<tr>
		<td align="right" width="50%"><bean:message key="formulario.item.venda.precoTotal" />: </td>
		<td align="left" width="50%"><bean:message key="sistema.moeda"/> <bean:write name="venda" property="valorTotal"/></td>
	</tr>		
	<tr>
		<td align="right" width="50%"><bean:message key="formulario.venda.valorDevido" />: </td>
		<td align="left" width="50%"><bean:message key="sistema.moeda"/> <bean:write name="venda" property="valorDevido"/></td>
	</tr>	
	<logic:equal name="venda" property="finalizada" value="false">
	<tr>
		<td>&nbsp;</td>
		<td align="right">
			<html:form action="/sistema/venda/finalizar">
				<html:hidden name="venda" property="vendaId"/>
				<html:submit>
					<bean:message key="formulario.venda.finalizar"/>
				</html:submit>
				<html:img pageKey="sistema.ico.dica" onclick="abrirJanelaDica('venda/finalizar.htm')" />
			</html:form>
		</td>
	</tr>
	</logic:equal>
</table>
<br>

<table class="tbForm">
	<tr>
		<th colspan="3" align="center"><bean:message key="formulario.venda.pagamentos" /></th>
	</tr>
	<tr>
		<th align="center"><bean:message key="formulario.venda.pagamento.data" /></th>
		<th align="center"><bean:message key="formulario.venda.pagamento.valor" /></th>
	</tr>
	<logic:iterate id="pagamento" name="venda" property="pagamentos">
			<tr>
				<td align="center"><bean:write name="pagamento" property="dataPagamento"  formatKey="sistema.padrao.data"/></td>
				<td align="center"><bean:write name="pagamento" property="valorPago" /></td>
			</tr>
	</logic:iterate>
	<tr>
		<td colspan="2" align="center">
			<logic:empty name="venda" property="pagamentos">
				<bean:message key="formulario.venda.pagamento.vazio" />
			</logic:empty>
		</td>
	</tr>
	<tr>
		<th align="right"><bean:message key="formulario.venda.pagamentos.total"/>: </th>
		<th align="left"><bean:message key="sistema.moeda"/> <bean:write name="venda" property="valorPago"/></th>
	</tr>

</table>
<br>
<br>
<html:form action="/sistema/venda/pagamento/adicionar" method="post">
	<table class="tbForm">
		<tr><th colspan="2" align="center"><bean:message key="formulario.venda.pagamento.adicionar" /></th></tr>
		<logic:messagesPresent message="false">
		<tr>
			<td colspan="2" class="erro">
				<bean:message key="formulario.informar.erros"/>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="erro">
				<html:messages id="mensagem" message="false" property="falha">
					<bean:write name="mensagem"/>
				</html:messages>
			</td>
		</tr>
		</logic:messagesPresent>
		<tr>
			<td valign="top" align="right"><bean:message key="formulario.venda.pagamento.data"/>:</td>
			<td align="left">
				<html:text property="dataPagamento"/> <html:img pageKey="sistema.ico.calendario" onclick="displayCalendar(document.forms[0].dataPagamento,'dd/mm/yyyy',this)"/>
				<html:img pageKey="sistema.ico.dica" onclick="abrirJanelaDica('venda/pagamento/data.htm')"/>
				<logic:messagesPresent message="false">
					<html:messages id="mensagem" message="false" property="dataPagamento">
						<br><span class="erro"><bean:write name="mensagem"/></span>
					</html:messages>
				</logic:messagesPresent>
			</td>
		</tr>
		<tr>
			<td valign="top" align="right"><bean:message key="formulario.venda.pagamento.valor" />:</td>
			<td align="left">
				<html:text property="valorPago" size="10" maxlength="8" />
				<html:img pageKey="sistema.ico.dica" onclick="abrirJanelaDica('venda/pagamento/valor.htm')" />
				<logic:messagesPresent message="false">
					<html:messages id="mensagem" message="false" property="valorPago">
						<br><span class="erro"><bean:write name="mensagem" /></span>
					</html:messages>
				</logic:messagesPresent>
			</td>
		</tr>
		<tr>
			<td></td>
			<td align="left">
				<html:submit><bean:message key="sistema.botao.venda.pagamento.adicionar" /></html:submit>
				<html:hidden name="venda" property="vendaId" />
			</td>
		</tr>
	</table>
</html:form>